/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.rational.sheet.table.cell.model.setting;

import java.awt.Font;

/**
 *
 * @author Overmind
 */
public class FontFormat
    implements FontConstants
{    
    public static final String DEFAULT_FONT_NAME = "Calibri";
    public static final int DEFAULT_FONT_SIZE = 11;
    public static final Thickness DEFAULT_THICKNESS = Thickness.PLAIN;
    public static final Slope DEFAULT_SLOPE = Slope.PLAIN;
    
    private String fontName;
    private int fontSize;
    private Thickness fontThickness;
    private Slope fontSlope;
    
    private Font font;

    public FontFormat()
    {
	this(DEFAULT_FONT_NAME, DEFAULT_FONT_SIZE,
		DEFAULT_THICKNESS, DEFAULT_SLOPE);
    }
    
    public FontFormat(String fontName, int fontSize,
            Thickness fontThickness, Slope fontSlope)
    {
        this.fontName = fontName;
        this.fontSize = fontSize;
        this.fontSlope = fontSlope;
        this.fontThickness = fontThickness;
        
        fontUpdate();
    }
    
    private void fontUpdate()
    {
        font = new Font(fontName, getStyle(), fontSize);
    }
    
    private int getStyle()
    {
        return fontThickness.getMask() | 
                fontSlope.getMask();
    }
    
    public Font getFont()
    {
        return font;
    }
    
    public String getName()
    {
        return fontName;
    }

    public int getSize()
    {
        return fontSize;
    }

    public Thickness getThickness()
    {
        return fontThickness;
    }

    public Slope getSlope()
    {
        return fontSlope;
    }
    
    public void setName(String fontName)
    {
        this.fontName = fontName;
        fontUpdate();
    }

    public void setSize(int fontSize)
    {
        this.fontSize = fontSize;
        fontUpdate();
    }

    public void setThickness(Thickness fontThickness)
    {
        this.fontThickness = fontThickness;
        fontUpdate();
    }

    public void setSlope(Slope fontSlope)
    {
        this.fontSlope = fontSlope;
        fontUpdate();
    }
}
